﻿Namespace Controls
    ''' <summary>
    ''' 网页进度条
    ''' </summary>
    ''' <remarks></remarks>
    Public Module HTextProgressBar
        ''' <summary>
        ''' 进度条的初始化
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub Start()
            Start("正在加载...")
        End Sub

        ''' <summary>
        ''' 进度条的初始化
        ''' </summary>
        ''' <param name="msg">最开始显示的信息</param>
        ''' <remarks></remarks>
        Public Sub Start(ByVal msg As String)
            Dim s As String = "<html xmlns=""http://www.w3.org/1999/xhtml"">" & Chr(13) & "" & Chr(10) & ""
            s &= "<head>" & Chr(13) & "" & Chr(10) & ""
            s &= "<title></title>" & Chr(13) & "" & Chr(10) & ""
            s &= "<script language=""javascript"" type=""text/javascript"">" & Chr(13) & "" & Chr(10) & ""
            s &= "<!--" & Chr(13) & "" & Chr(10) & ""
            's &= "var timerid;\r\n"; 
            's &= "var interval = 800;\r\n"; 
            's &= "function ShowPoint()\r\n"; 
            's &= "{\r\n"; 
            's &= "var obj = document.getElementById('TdPoint');\r\n"; 
            's &= "var s1 = obj.innerHTML;\r\n"; 
            's &= "if(s1 == '')\r\n"; 
            's &= "obj.innerHTML = '.';\r\n"; 
            's &= "else if(s1 == '.')\r\n"; 
            's &= "obj.innerHTML = '..';\r\n"; 
            's &= "else if(s1 == '..')\r\n"; 
            's &= "obj.innerHTML = '...';\r\n"; 
            's &= "else\r\n"; 
            's &= "obj.innerHTML = '';\r\n"; 
            's &= "timerid = setTimeout('ShowPoint()', 500);\r\n"; 
            's &= "}\r\n"; 
            s &= "function EndPoint(s)" & Chr(13) & "" & Chr(10) & ""
            s &= "{" & Chr(13) & "" & Chr(10) & ""
            's &= "clearTimeout(timerid);\r\n"; 
            s &= "document.getElementById('TdPoint').innerHTML = '';" & Chr(13) & "" & Chr(10) & ""
            s &= "SetText(s);" & Chr(13) & "" & Chr(10) & ""
            s &= "}" & Chr(13) & "" & Chr(10) & ""
            s &= "function SetText(s)" & Chr(13) & "" & Chr(10) & ""
            s &= "{" & Chr(13) & "" & Chr(10) & ""
            s &= "document.getElementById('TdText').innerHTML = s;" & Chr(13) & "" & Chr(10) & ""
            s &= "}" & Chr(13) & "" & Chr(10) & ""
            s &= "//-->" & Chr(13) & "" & Chr(10) & ""
            s &= "</script>" & Chr(13) & "" & Chr(10) & ""
            s &= "</head>" & Chr(13) & "" & Chr(10) & ""
            s &= "<body>" & Chr(13) & "" & Chr(10) & ""
            s &= "<table align=""center"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & Chr(13) & "" & Chr(10) & ""
            s &= "<tr style=""font-family: Verdana, Arial, Helvetica;font-size:11.5px;color: #DD5800;font-weight:bold"">" & Chr(13) & "" & Chr(10) & ""
            s &= "<td width=""70%"" id=""TdText"" align=""right"">" + msg + "</td>" & Chr(13) & "" & Chr(10) & ""
            s &= "<td width=""30%"" id=""TdPoint""><img src=""/sysImages/folder/loading.gif"" /></td>" & Chr(13) & "" & Chr(10) & ""
            s &= "</tr>" & Chr(13) & "" & Chr(10) & ""
            s &= "</table>" & Chr(13) & "" & Chr(10) & ""
            s &= "</body>" & Chr(13) & "" & Chr(10) & ""
            s &= "</html>"
            System.Web.HttpContext.Current.Response.Write(s)
            System.Web.HttpContext.Current.Response.Flush()
        End Sub

        ''' <summary>
        ''' 显示文本
        ''' </summary>
        ''' <param name="Msg"></param>
        ''' <remarks></remarks>
        Public Sub ShowText(ByVal Msg As String)
            Msg = Msg.Replace("'", "'")
            'Msg = Msg.Replace("\"",@"\""); 
            Dim jsBlock As String = "<script language=""javascript"">SetText('" + Msg + "');</script>"
            System.Web.HttpContext.Current.Response.Write(jsBlock)
            System.Web.HttpContext.Current.Response.Flush()
        End Sub

        ''' <summary>
        ''' 停止显示
        ''' </summary>
        ''' <param name="Msg"></param>
        ''' <remarks></remarks>
        Public Sub EndProgress(ByVal Msg As String)
            Dim jsBlock As String = "<script language=""javascript"">EndPoint('" + Msg + "');</script>"
            System.Web.HttpContext.Current.Response.Write(jsBlock)
            System.Web.HttpContext.Current.Response.Flush()
        End Sub
    End Module
End Namespace